Skip to content

fix: interactive-prd workflow bugs (#1001, #1002, #1003)#1005

Merged
Wirasm merged 3 commits intodevfrom
fix/issue-1001-1002-1003-interactive-prd
Apr 9, 2026
Merged

fix: interactive-prd workflow bugs (#1001, #1002, #1003)#1005
Wirasm merged 3 commits intodevfrom
fix/issue-1001-1002-1003-interactive-prd

Conversation

@Wirasm
Copy link
Copy Markdown
Collaborator

@Wirasm Wirasm commented Apr 9, 2026

Summary

  • Fix approval gates not capturing user responses — add capture_response: true to all three gates
  • Fix generate node writing to .claude/ (blocked by Claude SDK) — use $ARTIFACTS_DIR/prds/ instead
  • Fix CLI approve/reject creating new conversations — look up and reuse original conversation ID

Root Cause

Three independent bugs made archon-interactive-prd completely non-functional:

  1. fix(workflows): interactive-prd approval gates missing capture_response #1001: Gates were created before capture_response existed and never retrofitted
  2. fix(workflows): interactive-prd generate node writes to .claude/ which is blocked #1002: Prompt instructed AI to write to .claude/PRPs/prds/ which the Claude SDK blocks
  3. fix(cli): workflow approve creates new conversation instead of continuing original #1003: ApprovalOperationResult lacked conversationId, so CLI always generated a new one

Changes

File Change
.archon/workflows/defaults/archon-interactive-prd.yaml Add capture_response: true to 3 gates; change output path to $ARTIFACTS_DIR/prds/
packages/core/src/operations/workflow-operations.ts Add conversationId to ApprovalOperationResult and RejectionOperationResult; return it from all paths
packages/cli/src/commands/workflow.ts Accept conversationId option; look up original conversation in approve/reject commands
packages/cli/src/commands/workflow.test.ts Add getConversationById to conversation DB mock

Testing

  • Type check passes
  • All tests pass (including updated CLI test mock)
  • Lint passes
  • Format check passes

Fixes #1001, #1002, #1003

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced approval: node type to pause workflow execution for human review, with optional response capture for downstream use.
  • Improvements

    • Enhanced conversation context tracking in approval and rejection operations for better workflow continuity.

Wirasm added 2 commits April 9, 2026 17:04
…euse conversations (#1001, #1002, #1003)

The archon-interactive-prd workflow was completely non-functional due to three bugs:
approval gates didn't capture user responses (missing capture_response: true),
the generate node wrote to .claude/ which the Claude SDK blocks, and CLI
approve/reject created new conversations instead of reusing the original.

- Add capture_response: true to all three approval gates in the YAML
- Change output path from .claude/PRPs/prds/ to $ARTIFACTS_DIR/prds/
- Add conversationId to ApprovalOperationResult and RejectionOperationResult
- Look up and pass through original conversation ID in CLI approve/reject commands
- Add getConversationById mock to CLI workflow tests

Fixes #1001, #1002, #1003
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 9, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 570d9194-f791-432b-b54b-75fa3a184855

📥 Commits

Reviewing files that changed from the base of the PR and between 3459a52 and 168f040.

📒 Files selected for processing (4)
  • CLAUDE.md
  • packages/cli/src/commands/workflow.test.ts
  • packages/cli/src/commands/workflow.ts
  • packages/core/src/operations/workflow-operations.ts
✅ Files skipped from review due to trivial changes (2)
  • packages/core/src/operations/workflow-operations.ts
  • CLAUDE.md
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/cli/src/commands/workflow.ts
  • packages/cli/src/commands/workflow.test.ts

📝 Walkthrough

Walkthrough

This PR fixes approval gate response capture in the interactive-prd workflow and implements conversation ID preservation across approval and rejection operations. Changes include adding capture_response: true to three approval gates, updating PRD artifact output paths, extending interfaces to track conversation IDs, and enabling continued conversation context when resuming workflows.

Changes

Cohort / File(s) Summary
Workflow Configuration
.archon/workflows/defaults/archon-interactive-prd.yaml
Added capture_response: true to foundation-gate, deepdive-gate, and scope-gate approval blocks to enable user response capture. Updated PRD generation and validation paths from .claude/PRPs/prds/ to $ARTIFACTS_DIR/prds/.
Core Operations & Interfaces
packages/core/src/operations/workflow-operations.ts
Added conversationId: string field to ApprovalOperationResult and RejectionOperationResult interfaces. Updated approveWorkflow and rejectWorkflow to include conversationId: run.conversation_id in all return branches.
CLI Workflow Commands
packages/cli/src/commands/workflow.ts
Extended WorkflowRunOptions interface with optional conversationId?: string. Updated workflowApproveCommand and workflowRejectCommand to look up the original conversation by ID before resuming, preserving the platform conversation context with try/catch error handling.
CLI Workflow Tests
packages/cli/src/commands/workflow.test.ts
Extended conversation DB test mock with getConversationById. Added new test cases for workflowApproveCommand and workflowRejectCommand that verify conversation ID lookup and passage to getOrCreateConversation.
Documentation
CLAUDE.md
Added approval: node type documentation describing human gate behavior and capture_response: true output storage mechanism for reviewer comments.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related issues

  • #1002: The workflow configuration changes directly address the same approval gate nodes referenced in this issue.
  • #1003: The PR implements conversation ID lookup and preservation across workflow approval/rejection operations, enabling continued conversation context as described in this issue.

Poem

🐰 Hopping through gates with answers in hand,
Conversations preserved, oh isn't that grand!
Capture the responses, let workflows stay true,
From approval to rejection, the context flows through!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Out of Scope Changes check ❓ Inconclusive Changes extend beyond the single documented linked issue (#1001) to address #1002 (path fix) and #1003 (conversationId handling), which are not provided in the linked_issues input. The PR addresses three issues (#1001, #1002, #1003) but only #1001's requirements are documented in linked_issues. Verify that changes to workflow.ts, workflow-operations.ts, and CLAUDE.md directly satisfy the requirements of #1002 and #1003 as described in pr_objectives.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The PR title 'fix: interactive-prd workflow bugs (#1001, #1002, #1003)' clearly and concisely summarizes the main change—fixing three specific workflow bugs with issue references.
Description check ✅ Passed The PR description provides a clear summary with root causes, a change table, and testing evidence, matching the repository template's core requirements effectively.
Linked Issues check ✅ Passed The code changes fully address issue #1001's requirement: capture_response: true has been added to all three approval gates (foundation-gate, deepdive-gate, scope-gate) in the workflow YAML.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/issue-1001-1002-1003-interactive-prd

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Wirasm
Copy link
Copy Markdown
Collaborator Author

Wirasm commented Apr 9, 2026

Self Code Review

Summary

All three root causes correctly addressed. YAML fixes are clean, conversation threading is structurally sound.

Findings

Strengths

  • capture_response: true matches the existing schema exactly
  • $ARTIFACTS_DIR is the correct escape from .claude/ restrictions
  • conversationId added to both approval and rejection result types for consistency
  • Null-fallback on conversation lookup provides graceful degradation

Suggestions (non-blocking)

  • packages/cli/src/commands/workflow.ts:862 — Consider logging a warning when getConversationById returns null, since the silent fallback defeats the fix
  • packages/cli/src/commands/workflow.test.ts:108 — The mock always returns null; a test exercising the happy path (real conversation returned, platform ID passed through) would strengthen coverage for the fix(cli): workflow approve creates new conversation instead of continuing original #1003 fix

Security

  • No security concerns identified

Checklist

  • Fix addresses root causes from investigation
  • Code follows codebase patterns
  • Tests cover the change (mock updated)
  • No obvious bugs introduced

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
.claude/PRPs/issues/issue-1001-1002-1003.md (1)

11-11: Normalize Markdown structure to remove lint noise.

Line 11 jumps heading depth (###) without a preceding ##, and multiple fenced blocks are missing a language tag. This keeps triggering markdownlint warnings in PR artifacts.

Also applies to: 70-70, 164-164, 171-171, 181-181, 191-191, 199-199

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.claude/PRPs/issues/issue-1001-1002-1003.md at line 11, The markdown has
inconsistent heading depth and missing fenced-code language tags causing lint
warnings: change the "### Assessment" heading to the correct level (e.g., "##
Assessment" or add the missing parent "##" above it) so heading hierarchy is
sequential, and add explicit language identifiers (like ```md, ```text or the
appropriate language) to all fenced code blocks referenced (the fenced blocks
around the occurrences noted, including the blocks near the "Assessment" section
and at the other reported locations). Ensure all headings follow
increasing/decreasing levels without jumps and that every fenced block includes
a language tag to satisfy markdownlint.
packages/cli/src/commands/workflow.test.ts (1)

106-112: Add explicit assertions for conversation pass-through behavior.

The new mock unblocks execution, but current tests don’t verify that approve/reject actually call getConversationById(result.conversationId) and pass platform_conversation_id into the resumed run path.

As per coding guidelines, tests should validate command behavior in isolation with mocked dependencies.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/cli/src/commands/workflow.test.ts` around lines 106 - 112, The test
currently stubs getOrCreateConversation/getConversationById/updateConversation
but doesn't assert that approve/reject call
getConversationById(result.conversationId) or that the resumed run receives the
conversation's platform_conversation_id; update the tests in workflow.test.ts to
assert the mocked getConversationById was called with the returned
result.conversationId (use the mock for getConversationById) and add an
assertion that the resume/run-path (the function that continues execution after
approval/rejection) was invoked with the platform_conversation_id value from the
mocked conversation object (i.e., ensure the path that handles resuming receives
'platform_conversation_id' from getConversationById); keep the assertions
isolated to the mocks getOrCreateConversation, getConversationById, and
updateConversation so command behavior is validated without touching real
dependencies.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/cli/src/commands/workflow.ts`:
- Around line 865-867: The DB lookup for the original conversation
(conversationDb.getConversationById(result.conversationId)) is happening outside
the resume error-handling path so a DB error can abort before the existing
resume/fallback logic runs; move the lookup into the same try/catch used for
resume (or add explicit error handling) inside the approve/reject command flow
so failures are caught and handled consistently—ensure you reference
originalConversation and platformConversationId after the lookup only when
present, and if the lookup fails either fall back intentionally (document the
behavior) or throw a clear error to fail fast.

---

Nitpick comments:
In @.claude/PRPs/issues/issue-1001-1002-1003.md:
- Line 11: The markdown has inconsistent heading depth and missing fenced-code
language tags causing lint warnings: change the "### Assessment" heading to the
correct level (e.g., "## Assessment" or add the missing parent "##" above it) so
heading hierarchy is sequential, and add explicit language identifiers (like
```md, ```text or the appropriate language) to all fenced code blocks referenced
(the fenced blocks around the occurrences noted, including the blocks near the
"Assessment" section and at the other reported locations). Ensure all headings
follow increasing/decreasing levels without jumps and that every fenced block
includes a language tag to satisfy markdownlint.

In `@packages/cli/src/commands/workflow.test.ts`:
- Around line 106-112: The test currently stubs
getOrCreateConversation/getConversationById/updateConversation but doesn't
assert that approve/reject call getConversationById(result.conversationId) or
that the resumed run receives the conversation's platform_conversation_id;
update the tests in workflow.test.ts to assert the mocked getConversationById
was called with the returned result.conversationId (use the mock for
getConversationById) and add an assertion that the resume/run-path (the function
that continues execution after approval/rejection) was invoked with the
platform_conversation_id value from the mocked conversation object (i.e., ensure
the path that handles resuming receives 'platform_conversation_id' from
getConversationById); keep the assertions isolated to the mocks
getOrCreateConversation, getConversationById, and updateConversation so command
behavior is validated without touching real dependencies.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: cbd73ad5-e460-4581-a8a5-100f3b294d00

📥 Commits

Reviewing files that changed from the base of the PR and between 50f96f8 and 3459a52.

📒 Files selected for processing (5)
  • .archon/workflows/defaults/archon-interactive-prd.yaml
  • .claude/PRPs/issues/issue-1001-1002-1003.md
  • packages/cli/src/commands/workflow.test.ts
  • packages/cli/src/commands/workflow.ts
  • packages/core/src/operations/workflow-operations.ts

Comment thread packages/cli/src/commands/workflow.ts Outdated
@Wirasm
Copy link
Copy Markdown
Collaborator Author

Wirasm commented Apr 9, 2026

PR Review Summary

Critical Issues (2 found)

Agent Issue Location
silent-failure-hunter getConversationById call is outside try-catch in workflowApproveCommand — if DB throws after approval is already recorded, CLI crashes with raw stack trace and no recovery guidance packages/cli/src/commands/workflow.ts:~865
silent-failure-hunter Same unguarded getConversationById in workflowRejectCommand — identical crash risk packages/cli/src/commands/workflow.ts:~908

Fix: Wrap both lookups in try-catch, log at warn, fall back to undefined (generates new conversation ID — same as pre-PR behavior):

let platformConversationId: string | undefined;
try {
  const originalConversation = await conversationDb.getConversationById(result.conversationId);
  platformConversationId = originalConversation?.platform_conversation_id ?? undefined;
} catch (error) {
  const err = error as Error;
  log.warn({ err, runId, conversationId: result.conversationId }, 'cli.conversation_lookup_failed');
}

Important Issues (2 found)

Agent Issue Location
pr-test-analyzer Zero test coverage for the primary fix (bug #1003) — getConversationById mock always returns null, so only the fallback path is tested. The happy path (conversation found → ID passed through) is never asserted. packages/cli/src/commands/workflow.test.ts:110
code-reviewer WorkflowRunOptions.conversationId is ambiguously named — accepts a platform conversation ID but could be confused with the DB UUID in result.conversationId. A future caller could pass the wrong string. packages/cli/src/commands/workflow.ts:69

Suggestions (3 found)

Agent Suggestion Location
type-design-analyzer Rename conversationIdconversationDbId in ApprovalOperationResult / RejectionOperationResult, or add a JSDoc comment clarifying it's the DB UUID (not platform ID). Score: 6/10 overall — invariant expression (4/10) is the weakest dimension. packages/core/src/operations/workflow-operations.ts:36,44
silent-failure-hunter Add log.info when getConversationById returns null (fallback fires) so the graceful degradation is visible in logs packages/cli/src/commands/workflow.ts:~865,~908
docs-impact-agent approval: node type is missing from CLAUDE.md's DAG node types list (line 675). Since this PR confirmed that forgetting capture_response: true silently breaks $nodeId.output, documenting it prevents repeat mistakes. CLAUDE.md:675

Strengths

  • All three root causes correctly identified and fixed
  • capture_response: true additions are the right fix — schema already supports it
  • $ARTIFACTS_DIR substitution is well-established and avoids the Claude SDK .claude/ write block
  • Non-optional conversationId: string correctly reflects the invariant that workflow runs always have a conversation
  • RejectionOperationResult gets the same field — consistent treatment of both approve and reject paths

Documentation Issues

  • CLAUDE.mdapproval: node type absent from DAG node types list; should document capture_response: true behavior

CI Note

Verdict

NEEDS FIXES — 2 critical (unguarded DB calls) + 1 important (untested happy path)

Recommended Actions

  1. Wrap both getConversationById calls in try-catch with warn-level logging
  2. Add test case where getConversationById returns a real conversation and assert the platform ID is passed through
  3. Consider renaming or documenting the conversationId fields to disambiguate DB UUID vs platform ID
  4. Add approval: to CLAUDE.md node types list

instigator24 pushed a commit to instigator24/Archon that referenced this pull request Apr 9, 2026
…fix-output-format-approval

fix: correct AI node options docs claiming loop node support (coleam00#987)
- Wrap getConversationById calls in try-catch in CLI approve/reject
  commands to prevent crashes when DB errors occur after approval is
  already recorded (falls back to new conversation ID)
- Log when conversation lookup fails or returns null for observability
- Add happy-path tests verifying platform conversation ID is passed
  through in both approve and reject commands
- Add JSDoc comments clarifying conversationId is a DB UUID (not
  platform ID) in operation result interfaces and WorkflowRunOptions
- Document approval: node type in CLAUDE.md DAG node types list
@Wirasm Wirasm merged commit 5cfc7da into dev Apr 9, 2026
3 of 4 checks passed
@Wirasm Wirasm deleted the fix/issue-1001-1002-1003-interactive-prd branch April 9, 2026 16:36
leex279 pushed a commit that referenced this pull request Apr 9, 2026
* Investigate issues #1001, #1002, #1003: interactive-prd workflow bugs

* fix: interactive-prd workflow — capture responses, fix output path, reuse conversations (#1001, #1002, #1003)

The archon-interactive-prd workflow was completely non-functional due to three bugs:
approval gates didn't capture user responses (missing capture_response: true),
the generate node wrote to .claude/ which the Claude SDK blocks, and CLI
approve/reject created new conversations instead of reusing the original.

- Add capture_response: true to all three approval gates in the YAML
- Change output path from .claude/PRPs/prds/ to $ARTIFACTS_DIR/prds/
- Add conversationId to ApprovalOperationResult and RejectionOperationResult
- Look up and pass through original conversation ID in CLI approve/reject commands
- Add getConversationById mock to CLI workflow tests

Fixes #1001, #1002, #1003

* fix: guard conversation lookups, add tests, document approval node type

- Wrap getConversationById calls in try-catch in CLI approve/reject
  commands to prevent crashes when DB errors occur after approval is
  already recorded (falls back to new conversation ID)
- Log when conversation lookup fails or returns null for observability
- Add happy-path tests verifying platform conversation ID is passed
  through in both approve and reject commands
- Add JSDoc comments clarifying conversationId is a DB UUID (not
  platform ID) in operation result interfaces and WorkflowRunOptions
- Document approval: node type in CLAUDE.md DAG node types list
@Wirasm Wirasm mentioned this pull request Apr 10, 2026
Tyone88 pushed a commit to Tyone88/Archon that referenced this pull request Apr 16, 2026
…fix-output-format-approval

fix: correct AI node options docs claiming loop node support (coleam00#987)
Tyone88 pushed a commit to Tyone88/Archon that referenced this pull request Apr 16, 2026
…eam00#1003) (coleam00#1005)

* Investigate issues coleam00#1001, coleam00#1002, coleam00#1003: interactive-prd workflow bugs

* fix: interactive-prd workflow — capture responses, fix output path, reuse conversations (coleam00#1001, coleam00#1002, coleam00#1003)

The archon-interactive-prd workflow was completely non-functional due to three bugs:
approval gates didn't capture user responses (missing capture_response: true),
the generate node wrote to .claude/ which the Claude SDK blocks, and CLI
approve/reject created new conversations instead of reusing the original.

- Add capture_response: true to all three approval gates in the YAML
- Change output path from .claude/PRPs/prds/ to $ARTIFACTS_DIR/prds/
- Add conversationId to ApprovalOperationResult and RejectionOperationResult
- Look up and pass through original conversation ID in CLI approve/reject commands
- Add getConversationById mock to CLI workflow tests

Fixes coleam00#1001, coleam00#1002, coleam00#1003

* fix: guard conversation lookups, add tests, document approval node type

- Wrap getConversationById calls in try-catch in CLI approve/reject
  commands to prevent crashes when DB errors occur after approval is
  already recorded (falls back to new conversation ID)
- Log when conversation lookup fails or returns null for observability
- Add happy-path tests verifying platform conversation ID is passed
  through in both approve and reject commands
- Add JSDoc comments clarifying conversationId is a DB UUID (not
  platform ID) in operation result interfaces and WorkflowRunOptions
- Document approval: node type in CLAUDE.md DAG node types list
joaobmonteiro pushed a commit to joaobmonteiro/Archon that referenced this pull request Apr 26, 2026
…fix-output-format-approval

fix: correct AI node options docs claiming loop node support (coleam00#987)
joaobmonteiro pushed a commit to joaobmonteiro/Archon that referenced this pull request Apr 26, 2026
…eam00#1003) (coleam00#1005)

* Investigate issues coleam00#1001, coleam00#1002, coleam00#1003: interactive-prd workflow bugs

* fix: interactive-prd workflow — capture responses, fix output path, reuse conversations (coleam00#1001, coleam00#1002, coleam00#1003)

The archon-interactive-prd workflow was completely non-functional due to three bugs:
approval gates didn't capture user responses (missing capture_response: true),
the generate node wrote to .claude/ which the Claude SDK blocks, and CLI
approve/reject created new conversations instead of reusing the original.

- Add capture_response: true to all three approval gates in the YAML
- Change output path from .claude/PRPs/prds/ to $ARTIFACTS_DIR/prds/
- Add conversationId to ApprovalOperationResult and RejectionOperationResult
- Look up and pass through original conversation ID in CLI approve/reject commands
- Add getConversationById mock to CLI workflow tests

Fixes coleam00#1001, coleam00#1002, coleam00#1003

* fix: guard conversation lookups, add tests, document approval node type

- Wrap getConversationById calls in try-catch in CLI approve/reject
  commands to prevent crashes when DB errors occur after approval is
  already recorded (falls back to new conversation ID)
- Log when conversation lookup fails or returns null for observability
- Add happy-path tests verifying platform conversation ID is passed
  through in both approve and reject commands
- Add JSDoc comments clarifying conversationId is a DB UUID (not
  platform ID) in operation result interfaces and WorkflowRunOptions
- Document approval: node type in CLAUDE.md DAG node types list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(workflows): interactive-prd approval gates missing capture_response

1 participant